/*
 * @Author: 0x9DEFA478
 * @Date: 2024-01-13 18:32:46
 * @LastEditTime: 2024-02-16 00:00:32
 * @LastEditors: 0x9DEFA478
 * @Description: 
 * QQ:2652450237
 * ============================================================================================================================================
 * 
 * 
 * 
 *                                                                                               ************      ****************************
 *                                                                                             ************      ****************************  
 *                                                                                           ************      ****************************    
 *                                                                                         ************      ****************************      
 *                                                                                       ************      ************                        
 *                                                                                     ************      ************                          
 *                                                                                   ************      ************                            
 *                                                                                 ************      ************                              
 *                                                                               ************      ************                                
 *                                                                             ************      ************                                  
 *                                                                           ************      ************                                    
 *                                                                         ************      ************                                      
 *                                                                       ************      ************                                        
 *                                                                     ************      ************                                          
 *                                                                   ************      ************                                            
 *                                                                 ************      ************                                              
 *                                                               ************      ************                                                
 *                                                             ************      ************                                                  
 *                                                           ************      ************                                                    
 *                                                         ************      ************                                                      
 *                                                       ************      ************                                                        
 *                                                     ************      ************                                                          
 *                                                   ************      ************                                                            
 *                                                 ************      ************                                                              
 *                                               ************      ************                                                                
 *                                             ************      ************                                                                  
 *                                           ************      ************                                                                    
 *                                         ************      ************                                                                      
 *                                       ************      ************                                                                        
 *                                     ************      ************                                                                          
 *                                   ************      ************                                                                            
 *                                 ************      ************                                                                              
 *                               ************      ************                                                                                
 *                             ************      ************                                                                                  
 *                           ************      ************                                                                                    
 *                         ************      ************                                                                                      
 *       ****************************      ************                                                                                        
 *     ****************************      ************                                                                                          
 *   ****************************      ************                                                                                            
 * ****************************      ************                                                                                              
 * 
 * 
 * 
 * ============================================================================================================================================
 * 
 */
#ifndef hH_Concurrency_HPP_
#define hH_Concurrency_HPP_
#include "H_Type.hpp"




namespace H{

  namespace Concurrency{

    class SignalAbstract{
      public:
        SignalAbstract(){}
        ~SignalAbstract(){}

        virtual void wait()=0;
        virtual bool wait_ms(usize Timeout)=0;
        virtual bool wait_us(usize Timeout)=0;
        virtual void set()=0;
    };
#if __cplusplus >= 202000L
    template<class S>
    concept is_Signal=requires(S& s){
      s.wait();
      s.wait_ms((usize)1);
      s.wait_us((usize)1);
      s.set();
    };
#endif

    class LockAbstract{
      public:
        LockAbstract(){}
        ~LockAbstract(){}

        virtual void lock()=0;
        virtual void unlock()=0;
    };
#if __cplusplus >= 202000L
    template<class L>
    concept is_Lock=requires(L& l){
      l.lock();
      l.unlock();
    };
#endif

    class EmptySignal:public SignalAbstract{

      public:
        EmptySignal(){}
        ~EmptySignal(){}

        virtual void wait()override final{}
        virtual bool wait_ms(usize Timeout)override final{return true;}
        virtual bool wait_us(usize Timeout)override final{return true;}
        virtual void set()override final{}
    };

    class EmptyLock:public LockAbstract{

      public:
        EmptyLock(){}
        ~EmptyLock(){}

        virtual void lock()override final{}
        virtual void unlock()override final{}
    };

  }

}

#if __cplusplus >= 202000L
#define H_Concurrency_is_Signal H::Concurrency::is_Signal
#define H_Concurrency_is_Lock H::Concurrency::is_Lock
#else
#define H_Concurrency_is_Signal class
#define H_Concurrency_is_Lock class
#endif




#endif //hH_Concurrency_HPP_
